/**
 * Created by YY on 7/20/2016.
 */
angular.module('student', [
  'auth',
  'oc.lazyLoad',
  'ui.router'])
  .config(function ($ocLazyLoadProvider) {
    $ocLazyLoadProvider.config({
      modules: [{
        debug: true,
        name: 'student.qa',
        files: ['app/student/qa/qa.js']
      }, {
        debug: true,
        name: 'student.doc',
        files: ['app/student/doc/doc.js']
      }, {
        debug: true,
        name: 'student.person',
        files: ['app/student/person/person.js']
      }, {
        debug: true,
        name: 'student.sign',
        files: ['app/student/sign/sign.js']
      }, {
        debug: true,
        name: 'student.class',
        files: ['app/student/class/class.js']
      }]
    })
  })
  .config(function ($stateProvider) {
    $stateProvider
      .state('student', {
        url: '/student',
        templateUrl: 'app/student/student.html',
        controller: 'studentCtrl',
        resolve: {
          lazy: function ($ocLazyLoad) {
            return $ocLazyLoad.load([
              'student.class',
              'student.sign',
              'student.person',
              'student.qa',
              'student.doc']);
          }
        }
      })
    })
    .controller('studentCtrl', function ($scope, $mdSidenav, $location, checkCredit) {
        if (!checkCredit(1)) {
            $location.path('/login');
        }
        $scope.classname = '高数课';
        $scope.username = '王亦凡';
        $scope.items = [
            {
               sref:'student.class',
               content:'班级',
               icon:'class'
           },{
               sref:'student.doc',
               content:'课件',
               icon:'description'
           },{
               sref:'student.person',
               content:'个人',
               icon:'person'
           },{
               sref:'student.qa',
               content:'问答',
               icon:'help'
           },{
               sref:'student.sign',
               content:'签到',
               icon:'fingerprint'
           }
       ];
       var toggle = function () {
           $mdSidenav('left').toggle();
       };
       $scope.toggleList = toggle;
    });
